/**
 * Created with Vim7.3 ubuntu12.04
 * @fileOverview : 
 * @author : Lyle <lylechen2014@gmial.com>
 * @since : 2015-01-30 14:46:00
 * @filename : panel/panel.js
 * @version : 
 * @description : 底部的模块不移动，只是面板移动。2种方式实现，位置移动和偏移量移动 
 */

;(function(){

     var panel = function(opt) {
         
         this.panel = {
              width : 260,
               type : 'cssTranslate' //[cssPosition,cssTranslate]
         };

         this.init = function(opt) {
              this[this.panel.type]($('#'+opt.id),-this.panel.width,200);
         };
 
         this.open = function(id) {
              this[this.panel.type]($('#'+opt.id),0,200);
              $('#'+opt.id).find('.panel_dismiss').css({
                  display : 'block',
                  width : ($(window).width()-this.panel.width)+'px'    
              });
         };

         this.close = function() {
              this[this.panel.type]($('#'+opt.id),-this.panel.width,200);
              $('#'+opt.id).find('.panel_dismiss').css({
                  display : 'none',
                  width : ($(window).width()-this.panel.width)+'px'    
              });
         };
        
         //css3偏移 
         this.cssTranslate = function(dom,move,time) {
              dom.css({
                   '-webkit-transform' : 'translate3d('+move+'px, 0px, 0px)',
                   '-moz-transform' : 'translate3d('+move+'px, 0px, 0px)',
                   'transform' : 'translate3d('+move+'px, 0px, 0px)',
                   'display':'block',
                   'transition': time+'ms linear',
                   '-webkit-transition': time+'ms linear', 
                   '-moz-transition': time+'ms linear'
              }); 
         };
         
         //位置移动
         this.cssPosition = function(dom,move,time) {
              dom.css({
                   'left': move+'px',
                   'display':'block',
                   'transition': time+'ms linear',
                   '-webkit-transition': time+'ms linear', 
                   '-moz-transition': time+'ms linear'
              });      
         };

         this.init(opt);

     };

     window.panel = panel;

})()
